<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>入库调度（点击调度）</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/css/animate.css" rel="stylesheet">
    <link href="/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="/bootstraptable/bootstrap-table.css" rel="stylesheet">
    <style>
        .text_no_border{
            border:none;
        }
    </style>
</head>
<body>
<div style="color: #0e9aef;">您正在做的业务是：库存管理--出入库调度管理--制定入库单</div>
<div class="container">
    <div style="text-align: right;">
        <button type="button" class="btn btn-default" onclick="javascript:history.back()">返回</button>
    </div>
    <div class="panel panel-default" style="margin-top: 5px;">
        <div class="page-heading">
            <div class="panel-title">
                <h2 style="text-align: center;margin-top: 20px;">入库调度单</h2>
            </div>
        </div>
        <div class="panel-body">
            <form class="form-horizontal" id="inbound_scheduling_byId_form">
                <div class="form-group">
                    <div class="col-md-6">
                        <label class="control-label col-md-4">入库单编号：</label>
                        <div class="col-md-8">
                            <input type="text" class="text_no_border form-control"
                                   readonly style="background-color: white;" id="gatherId">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-6">
                        <label class="control-label col-md-4">入库理由：</label>
                        <div class="col-md-8">
                            <input type="text" class="text_no_border form-control"
                                   readonly style="background-color: white;" id="reason">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <label class="control-label col-md-4">入库详细理由：</label>
                        <div class="col-md-8">
                            <input type="text" class="text_no_border form-control"
                                   readonly style="background-color: white;" id="reasonexact">
                        </div>
                    </div>
                </div>
                <table style="margin-top: 20px;" class="table table-bordered table-striped" data-toggle="table" id="inbound_scheduling_details_byId_table">
                    <thead>
                        <tr>
                            <th data-field="productName">产品名称</th>
                            <th data-field="productId">产品编号</th>
                            <th data-field="amount">应入库件数</th>
                            <th data-field="gatheredAmount">已入库件数</th>
                            <th data-field="dispatch" data-formatter="formatterDispatch">调度</th>
                        </tr>
                    </thead>
                </table>

                <div class="form-group">
                    <div class="col-md-6">
                        <label class="control-label col-md-4">应入库总件数：</label>
                        <div class="col-md-8">
                            <input type="text" class="text_no_border form-control"
                                   readonly style="background-color: white;" id="amountSum">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <label class="control-label col-md-4">应入库总成本：</label>
                        <div class="col-md-8">
                            <input type="text" class="text_no_border form-control"
                                   readonly style="background-color: white;" id="costPriceSum">
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>


<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/js/plugins/layer/layer.min.js"></script>

<!-- 自定义js -->
<script src="/js/hAdmin.js?v=4.1.0"></script>
<script src="/js/currentTime.js"></script>

<!-- 第三方插件 -->
<script src="/js/plugins/pace/pace.min.js"></script>

<!--BootstrapTable-->
<script src="/bootstraptable/bootstrap-table.min.js"></script>
<script src="/bootstraptable/locale/bootstrap-table-zh-CN.min.js"></script>

<script>
    $(function (){
        let id=localStorage.getItem("id")
        $.post("/storage/gather/getByIdStorageGather",{"id":id},function (res){
            $("#inbound_scheduling_byId_form #gatherId").val(res.gatherId)
            $("#inbound_scheduling_byId_form #reasonexact").val(res.reasonexact)
            $("#inbound_scheduling_byId_form #amountSum").val(res.amountSum)
            $("#inbound_scheduling_byId_form #costPriceSum").val(res.costPriceSum)
            $("#inbound_scheduling_byId_form #gatheredAmountSum").val(res.gatheredAmountSum)
            if(res.reason=="R001-1"){
                $("#inbound_scheduling_byId_form #reason").val("生产入库")
            }else if (res.reason=="R001-2"){
                $("#inbound_scheduling_byId_form #reason").val("库存初始")
            }else if (res.reason=="R001-3"){
                $("#inbound_scheduling_byId_form #reason").val("赠送")
            }else if (res.reason=="R001-4"){
                $("#inbound_scheduling_byId_form #reason").val("内部归还")
            }else {
                $("#inbound_scheduling_byId_form #reason").val("其他归还")
            }
        })

        $.post("/storage/gather/getByIdStorageGatherDetails",{"id":id},function (res){
            for(let i=0;i<res.length;i++){
                $("#inbound_scheduling_details_byId_table").bootstrapTable("append",res[i])
            }
        })

    })

    function formatterDispatch(value,row,index){
        if(row.gatherTag=="K002-1"){
            return `<a href="javascript:getById(${row.id})">调度</a>`
        }
       return `<a style="color: black;">完成</a>`
    }

    function getById(detailsId){
        localStorage.setItem("detailsId",detailsId)
        let gatherId=$("#inbound_scheduling_byId_form #gatherId").val()
        localStorage.setItem("gatherId",gatherId)
        $.post("/storage/gather/getByProductIdMake",{"id":detailsId},function (res){
            if(res){
                window.location="establish_inbound_schedulingUI"
            }else {
                window.location="errorUI"
            }
        })
    }
</script>
</body>
</html>